//
//  WeSellerMessageHeaderInfoView.m
//  WeGalaxy
//
//  Created by Zheng on 2017/7/24.
//  Copyright © 2017年 Zheng. All rights reserved.
//

#import "WeSellerMessageHeaderInfoView.h"
#import "WeSellerMessageModel.h"

@implementation WeSellerMessageHeaderInfoView

- (void)setModel:(WeSellerMessageModel *)model {
    _model = model;
    
    [_iconImgv sd_setImageWithURL:[NSURL URLWithString:_model.pic] placeholderImage:nil];
    _priceLbl.text = [NSString stringWithFormat:@"当前价 ¥ %@",_model.price];
    _subTitleLbl.text = _model.des;
    
}

#pragma mark - 子视图
- (void)subviewsInView {
    [self addSubview:self.iconImgv];
    [self addSubview:self.priceLbl];
    [self addSubview:self.subTitleLbl];
    [self addSubview:self.lineView];
    
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self);
        make.height.mas_equalTo(0.7);
    }];
    
    [_iconImgv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(7);
        make.centerY.equalTo(self);
        make.width.height.mas_equalTo(75);
    }];
    
    [_priceLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(_iconImgv.mas_right).offset(20);
        make.top.mas_equalTo(25);
        make.right.mas_equalTo(-20);
    }];
    
    [_subTitleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(_priceLbl);
        make.bottom.mas_equalTo(-12);
    }];
}

- (UIImageView *)iconImgv {
    if (!_iconImgv) {
        _iconImgv = [[UIImageView alloc] init];
        _iconImgv.layer.borderColor = [[UIColor grayColor] CGColor];
        _iconImgv.layer.borderWidth = 1.f;
    }
    return _iconImgv;
}

- (UILabel *)priceLbl {
    if (!_priceLbl) {
        _priceLbl = [[UILabel alloc] init];
        _priceLbl.font = kCX_FONT(16);
    }
    return _priceLbl;
}

- (UILabel *)subTitleLbl {
    if (!_subTitleLbl) {
        _subTitleLbl = [[UILabel alloc] init];
        _subTitleLbl.textColor = [UIColor grayColor];
        _subTitleLbl.font = kCX_FONT(14);
    }
    return _subTitleLbl;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [UIView new];
        _lineView.backgroundColor = kRGB_COLOR(200, 199, 204, 1);
    }
    return _lineView;
}

#pragma mark - 初始化
- (instancetype)init {
    self = [super init];
    if (!self) return nil;
    [self subviewsInView];
    return self;
}

@end
